package com.android.boncen.commonFrame.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageButton;
import android.widget.TextView;

import com.android.boncen.commonFrame.R;

public class Webview_detail_activity extends Activity implements View.OnClickListener {
    private WebView webview;
    private TextView tvTitle;
    private ImageButton ibBack;
    private String title;
    private String url;
    private int position;   //表示cookbook的点击位置
    /**
     * Find the Views in the layout<br />
     * <br />
     * Auto-created on 2017-01-30 20:12:22 by Android Layout Finder
     * (http://www.buzzingandroid.com/tools/android-layout-finder)
     */
    private void findViews() {
        tvTitle = (TextView)findViewById( R.id.tv_title );
        ibBack = (ImageButton)findViewById( R.id.ib_back );
        webview = (WebView)findViewById( R.id.webview);
        ibBack.setOnClickListener( this );
        ibBack.setVisibility(View.VISIBLE);
    }
    @Override
    public void onClick(View v) {
        if ( v == ibBack ) {
            finish();   //返回
        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_cookbook_detail_activity);
        findViews();
        getData();
    }

    private void getData() {
         title =  getIntent().getStringExtra("title");
        url = getIntent().getStringExtra("url");
        tvTitle.setText(title);
        WebSettings webSettings = webview.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webview.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
            }
        });
        webview.loadUrl(url);
    }


}
